// AUTO GENERATED CODE!
// CODE GENERATOR WILL NOT PRESERVE MANUAL CHANGES TO THIS CODE!
// 

// MIT License (MIT)
// 
// Copyright (c) 2014 K Ercan Turkarslan
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// 


using System;

namespace Mios.Generated.ServiceFiles
{
    // Generated from S_EnergyMetering1.xml
    
    public class EnergyMetering1Service : MiosService
    {
        #region Watts : UInt32;
        private UInt32? _mWatts;
        
        public UInt32 Watts
        {
            get
            {
                return _mWatts ?? GetWatts();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action GetWatts() : UInt32;
        public UInt32 GetWatts()
        {
            _mWatts = FromLuupUInt32(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "Watts"));
            
            return _mWatts.Value;
        }
        #endregion Action GetWatts
        
        #endregion
        
        #region ActualUsage : Boolean;
        private Boolean? _mActualUsage;
        
        public Boolean ActualUsage
        {
            get
            {
                return _mActualUsage ?? GetActualUsage();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action GetActualUsage() : Boolean;
        public Boolean GetActualUsage()
        {
            _mActualUsage = FromLuupBoolean(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "ActualUsage"));
            
            return _mActualUsage.Value;
        }
        #endregion Action GetActualUsage
        
        #endregion
        
        #region WholeHouse : Boolean;
        private Boolean? _mWholeHouse;
        
        public Boolean WholeHouse
        {
            get
            {
                return _mWholeHouse ?? GetWholeHouse();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action GetWholeHouse() : Boolean;
        public Boolean GetWholeHouse()
        {
            _mWholeHouse = FromLuupBoolean(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "WholeHouse"));
            
            return _mWholeHouse.Value;
        }
        #endregion Action GetWholeHouse
        
        #endregion
        
        #region Pulse : UInt32;
        private UInt32? _mPulse;
        
        public UInt32 Pulse
        {
            get
            {
                return _mPulse ?? GetPulse();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action GetPulse() : UInt32;
        public UInt32 GetPulse()
        {
            _mPulse = FromLuupUInt32(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "Pulse"));
            
            return _mPulse.Value;
        }
        #endregion Action GetPulse
        
        #endregion
        
        #region UserSuppliedWattage : UInt32;
        private UInt32? _mUserSuppliedWattage;
        
        public UInt32 UserSuppliedWattage
        {
            get
            {
                return _mUserSuppliedWattage ?? GetUserSuppliedWattage();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action GetUserSuppliedWattage() : UInt32;
        public UInt32 GetUserSuppliedWattage()
        {
            _mUserSuppliedWattage = FromLuupUInt32(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "UserSuppliedWattage"));
            
            return _mUserSuppliedWattage.Value;
        }
        #endregion Action GetUserSuppliedWattage
        
        #endregion
        
        #region KWH : UInt32;
        private UInt32? _mKWH;
        
        public UInt32 KWH
        {
            get
            {
                return _mKWH ?? GetKWH();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action GetKWH() : UInt32;
        public UInt32 GetKWH()
        {
            _mKWH = FromLuupUInt32(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "KWH"));
            
            return _mKWH.Value;
        }
        #endregion Action GetKWH
        
        #endregion
        
        
        #region Action ResetKWH()
        public void ResetKWH()
        {
            Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "ResetKWH");
        }
        #endregion Action ResetKWH
        
        
        #region Method SetVariable(String name, String value) : Boolean;
        internal override Boolean SetVariable(String name, String value)
        {
            switch(name)
            {
                case "ActualUsage":
                    _mActualUsage = FromLuupBoolean(value); return true;
                case "KWH":
                    _mKWH = FromLuupUInt32(value); return true;
                case "Pulse":
                    _mPulse = FromLuupUInt32(value); return true;
                case "UserSuppliedWattage":
                    _mUserSuppliedWattage = FromLuupUInt32(value); return true;
                case "Watts":
                    _mWatts = FromLuupUInt32(value); return true;
                case "WholeHouse":
                    _mWholeHouse = FromLuupBoolean(value); return true;
                default:
                    return false;
            }
        }
        #endregion Method SetVariable
        
        public EnergyMetering1Service(MiosEngine engine, UInt32 deviceId, String serviceId)
            : base(engine, deviceId, serviceId)
        {
            
        } //End Constructor
    } //End of class
} //End of Namespace

